<template>
    <el-affix :offset="0" :z-index="9999">
        <el-menu :default-active="activeIndex" mode="horizontal" router :ellipsis="false" @select="handleSelect">
            <!-- active-text-color="#9286D1"> -->
            <Logo></Logo>
            <el-menu-item index="/home">首页</el-menu-item>
            <el-menu-item index="/blog">博客</el-menu-item>
            <div class="flex-grow"></div>
            <el-sub-menu index="/login">
                <template #title>
                    <el-avatar :size="50" :src="avatarURL" />
                </template>
                <el-menu-item index="/user">个人中心</el-menu-item>
                <el-menu-item index="/login">退出</el-menu-item>
            </el-sub-menu>
            <el-menu-item index="/editor" disabled>发布</el-menu-item>
        </el-menu>
    </el-affix>
</template>
  
<script setup>
import Logo from '@/components/Logo/index.vue'
import { computed } from 'vue'
import { useRoute } from "vue-router"
import avatarURL from '@/assets/images/wy.png'

const route = useRoute()
const activeIndex = computed(() => {
    return '/' + route.fullPath.split("/")[1]
})
const handleSelect = (key, keyPath) => {
    // console.log(key, keyPath)
}
</script>
  
<style lang="scss" scoped>
.flex-grow {
    flex-grow: 1;
}

.el-menu {
    padding: 0 20px;
}
</style>
  